<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------

use \think\facade\Route;

Route::rule('client/product/upgrade', 'api/ProductUpgrade/ReceiveUpgrade');//接收新服务端地址通知
Route::rule('client/product/getInstallPackagePath', 'api/ProductUpgrade/getInstallPackagePath');//获取安装包
Route::rule('client/product/ResultStatus', 'api/ProductUpgrade/ResultStatus');//回传状态

Route::group('api/v3',  function () {
    Route::rule('learn/data/handle', 'api/LearnData/handle');//学习完之后数据处理
    Route::rule('link/index', 'api/Link/index');//检测连接

    Route::rule('export/netfilter', 'api/Export/netfilterLog');//Netfilter日志导出
    Route::rule('export/rule', 'api/Export/rule');//规则导出



    Route::rule('client/update/timeout', 'api/ProductUpdate/timeOut');//超时断连问题
    Route::rule('client/update/getpackagepath', 'api/ProductUpdate/getPackagePath');//获取客户端更新包内容
    Route::rule('client/update/downloadresult', 'api/ProductUpdate/downloadResult');//下载客户端更新包结果通知
    Route::rule('update/updateresult', 'api/ProductUpdate/updateResult');//更新包执行结果通知

    //服务端配置获取
    Route::group('config',  function () {
        Route::rule('get/databasebyhostid', 'api/Config/databaseByHostId');//获取数据库连接
        Route::rule('get/syslog', 'api/Config/syslog');//获取syslog配置
        Route::rule('get/database', 'api/Config/database');//获取数据库配置
        Route::rule('set/portconfig', 'api/Config/portConfig');//修改端口配置
        Route::rule('get/server', 'api/Config/server');//获取服务端配置
    });



    Route::group('client',  function () {
        Route::rule('register', 'api/ClientRegister/reg');//注册
        Route::rule('login/netfilter', 'api/ClientLogin/netfilter');//netfilter模块登陆
        Route::rule('login/client', 'api/ClientLogin/client');//客户端模块登陆
        Route::rule('login/disguise', 'api/ClientLogin/disguise');//端口伪装登陆
        Route::rule('login/hgshield', 'api/ClientLogin/hgshield');//函谷盾登录
    });
    
    Route::group('netfilter',  function () {
        //防火墙规则上传
        Route::rule('firewall_rule/upload', 'api/netfilter.FirewallRuleUpload/upload');
        //防火墙规则下载
        Route::rule('firewall_rule/download', 'api/netfilter.FirewallRuleDownload/download');
        //本地规则排序组件 推送 排序后规则
        Route::rule('firewall_rule/sort', 'api/netfilter.FirewallRuleSort/autoSort');
        //更改防火墙接管状态为已接管
        Route::post('setControlledFirewall','api/netfilter.HostLearnConfig/setControlledFirewall');
    });

    Route::rule('middleware/register', 'api/ServerMiddleware/register');//中间键注册
    Route::rule('middleware/update/getpackagepath', 'api/ServerMiddleware/getPackagePath');//获取中间件更新包内容

    //下发命令回调接口
    Route::group('directive',function (){
        //防火墙
        Route::group('netfilter',function (){
            Route::rule('study', 'api/directive.netfilter.Study/study');//学习
            Route::rule('firewallConfig', 'api/directive.netfilter.Config/firewallConfig');//防火墙配置
            Route::rule('firewallLogStatus', 'api/directive.netfilter.Log/firewallLogStatus');//防火墙日志状态
            Route::rule('controlledFirewall', 'api/directive.netfilter.Netfilter/controlledFirewall');//接管防火墙
        });

        //系统伪装
        Route::group('disguise',function (){
            //伪装信息
            Route::rule('info', 'api/directive.disguise.DisGuise/info');
        });
        //客户端client
        Route::group('client',function (){
            //模块信息
            Route::rule('modules', 'api/directive.client.Client/modules');
            Route::rule('uninstall', 'api/directive.client.Client/uninstall');
        });

    });

    //处理数据
    Route::group('handleData',function (){
        //客户端client
        Route::group('client',function (){
            Route::rule('resource', 'api/handleData.client.Client/resource');//主机资源上传
            Route::rule('port', 'api/handleData.client.Client/port');//上传所有端口
        });
    });

    Route::group('log',function (){
        Route::rule('error/upload', 'api/log.ErrorLog/upload');//上传错误日志
    });



});